<?php if ( ! defined( 'BASEPATH' ) ) exit( 'No direct script access allowed' );
/**
 * BackendPro
 *
 * A website backend system for developers for PHP 4.3.2 or newer
 *
 * @package         conlabz CMS
 * @author          Christian Schneider
 * @copyright       Copyright (c) 2009
 * @license        
 * @link            http://www.conlabz.de
 * @filesource
 */

// ---------------------------------------------------------------------------

/**
 * Language
 *
 * Allows to manage languages
 *
 * @package         conlabz CMS
 * @subpackage      Controllers
 */
class Language extends Admin_Controller {
	
	function Language( ) {
		parent::Admin_Controller( );
		
		$this->load->helper( 'form' );

		// Check for access permission
		// needs to be defined as a resource over the admin area
		check( 'Language' );

		// Load the validation library
		$this->load->library( 'validation' );

		// Load the website model
		$this->load->model( 'language_model' );
		
		// Load the language files
		$this->lang->module_load( 'article', 'website' );
		$this->lang->module_load( 'article', 'classification' );
		$this->lang->module_load( 'article', 'domain' );
		$this->lang->module_load( 'article', 'language' );
		$this->lang->module_load( 'article', 'portlets' );

		// Set breadcrumb
		$this->bep_site->set_crumb( $this->lang->line( 'language' ), 'article/admin/language' );

		log_message( 'debug', 'conlabz CMS : Language class loaded' );
	}	
	
	/**
	 * View Language
	 *
	 * @access public
	 */
	function index( ) {
		// Get Language Infomation
		$data['languages'] = $this->language_model->getLanguages( );

		// Display Page
		$data['header'] = $this->lang->line( 'language_overview' );
		$data['page']   = $this->config->item( 'backendpro_template_admin' ) . "/view_language";
		$data['module'] = 'article';
		$this->load->view( $this->_container, $data );
	}
	
	/**
	 * Delete Language
	 *
	 * @access public
	 */
	function delete( ) {	
		if( FALSE === ( $selected = $this->input->post( 'select' ) ) ) {
			redirect( 'article/admin/language', 'location' );
		}
		
		foreach( $selected as $language ) {
			$this->db->delete( 'language', array( 'id' => $language ) );
		}
		
		flashMsg( 'success', $this->lang->line( 'language_deleted' ) );
		redirect( 'article/admin/language', 'location' );	
	}
}
/* End of file language.php */
/* Location: ./modules/article/controllers/admin/language.php */